import { Component, OnInit, ViewChild, TemplateRef } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { NzMessageService, NzModalService } from 'ng-zorro-antd';
import { STColumn, STComponent, STData } from '@delon/abc';
import { SPage, ColumnType } from '@shared/components/table-page/table-page.component';
import { ACLService } from '@delon/acl';

@Component({
  selector: 'manager-list',
  templateUrl: './manager-list.component.html',
})
export class ManagerListComponent implements OnInit {
  @ViewChild('st', { static: false }) st: STComponent;
  config: SPage = {
    columns: [
      {
        index: 'infoName',
        title: '姓名',
        filter: {
          placeholder: '请输入姓名',
          type: 'string'
        }
      },
      {
        index: 'infoMobile',
        title: '手机号',
        filter: {
          placeholder: '请输入手机号',
          type: 'string'
        }
      },
      {
        index: 'houseName',
        title: '区域名称',
        filter: {
          placeholder: '请输入区域地址',
          type: 'string'
        }
      },
      {
        index: 'roomName',
        title: '房间号',
        filter: {
          placeholder: '请输入房间号',
          type: 'string'
        }
      },
    
    ],
    showCheckBox: true,
    editBtn:[
      //{title:'查看出入记录'},
      {title:'审批通过'},
      {title:'拒绝审批'},
    ],
    reqUrl:'/core/room/person/queryApproveList'
  }
  constructor(private http: _HttpClient, private modal: ModalHelper,private aclService: ACLService, private message: NzMessageService,) { }

  ngOnInit() { }

  // 根据状态检索不需要被全选的数据
  dataProcess(data) {
      return data
  }
  operate(e: any): void {
    if (e.title === '审批通过') {
      this.editDic(e.data,1)
    }else if(e.title == '拒绝审批'){
      this.editDic(e.data,2)
    }else if(e.title == '编辑'){

    }else if(e.title == '删除'){

    }
  }
  editDic(param,status):void{
    this.http.request<any>('post','/core/room/person/approvePass',{body:{id:param.id,roomApprove:status}}).subscribe(res => {
      if(res.status === '200'){
        this.message.success('审批成功');
        this.st.reload();
      }else{
        this.message.error(res.message)
      }
    })
  }
  // 选择数据
  selectChange(e) {
  }

}
